import { createSlice, PayloadAction } from '@reduxjs/toolkit'
import { User } from '@/types/user'

// const USER_KEY = 'higo-2306-user'

const userSlice = createSlice({
  name: 'user',
  // initialState: JSON.parse(localStorage.getItem(USER_KEY) || '{}') as User,
  initialState: {} as Partial<User>,
  reducers: {
    setUserInfo (_, action: PayloadAction<Partial<User>>) {
      return action.payload
    }
  }
})

export const { setUserInfo } = userSlice.actions

export default userSlice.reducer
